import 'package:flutter/material.dart';

mixin ScreenLoadMixin<T extends StatefulWidget> on State<T> {

  bool isHide = false;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Offstage(
          offstage: isHide,
          child: const Center(child: CircularProgressIndicator()),
        ),
        Offstage(
          offstage: !isHide,
          child: buildChild(context),
        ),
      ],
    );
  }

  Widget buildChild(BuildContext context);

  void loadFinish() {
    setState(() => isHide = true);
  }
}